/*$Id$*/
package com.leetech.gwt.client;

import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;



public class ErrorDialogBox extends DialogBox {

    // Static initialization-------------------------------------------
    // Instance variables----------------------------------------------
    // Constructors----------------------------------------------------
    ErrorDialogBox(Throwable thrown) {
          setText(thrown.toString());
          VerticalPanel popPanel = new VerticalPanel();
          thrown.printStackTrace();
          StackTraceElement[] trace = thrown.getStackTrace();
          for(int i=0;i<trace.length;i++){
              popPanel.add(new Label(
                      trace[i].getClassName()+"."+
                      trace[i].getMethodName()+":"+
                      trace[i].getFileName()+"["+
                      trace[i].getLineNumber()+"]\n"));
              }
          popPanel.add(new Button("Close",new ClickListener(){
            public void onClick(Widget sender) {
                hide();
            }}));
          setWidget(popPanel);
          show();
    }
    
    ErrorDialogBox(String html) {
          setText("Error");
          VerticalPanel popPanel = new VerticalPanel();
          popPanel.add(new HTML(html));
          popPanel.add(new Button("Close",new ClickListener(){
            public void onClick(Widget sender) {
                hide();
            }}));
          setWidget(popPanel);
          show();
    }
    // Methods---------------------------------------------------------
    // Inner Classes --------------------------------------------------
}

